package com.javaweb.controller;

import com.javaweb.controller.common.ResponseResult;
import com.javaweb.service.dto.UserDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @desc:
 * @author: Ping
 * @date: 2024/11/6 15:07
 */

@RestController
@RequestMapping("/resource")
@Slf4j
public class DataTransferController {

    @GetMapping("/param/simple")
    public ResponseResult<String> processSimpleParam(
            @RequestParam  String username,
            @RequestParam(defaultValue = "123456") String password) {
        log.info("username: {}, password: {}", username, password);
        return ResponseResult.ok("success");
    }

    @PostMapping("/param/object")
    public ResponseResult<String> processObjectParam(UserDto userDto) {
        log.info("username: {}, password: {}, datetime: {}",
                userDto.getUsername(), userDto.getPassword(),
                userDto.getCreateTime());
        return ResponseResult.ok("success");
    }

    @PostMapping("/param/json")
    public ResponseResult<String> processJsonParam(
            @RequestBody UserDto userDto) {
        log.info("username: {}, password: {}, datetime: {}",
                userDto.getUsername(), userDto.getPassword(),
                userDto.getCreateTime());
        return ResponseResult.ok("success");
    }





}
